package Agent;

import java.util.Scanner;
import java.util.Vector;

import Env.Car;
import Env.Environment;

public class HumanAgent extends AbstractAgent {

	public HumanAgent(int start, Environment env) {
		super(start, 0, env);
	}

	@Override
	protected void chooseCarAndVertex() throws Exception {
		boolean repeat=false;
		Scanner scanner= new Scanner (System.in);
		Vector<Integer> vertexes=env.getGraph().getAllConnected(position);
		Vector<Car> cars = env.getCars(position);
		if (cars.isEmpty()){
			chosenCar=null;
			return ;
		}
			
		int chosenVertex;
		int iCar=0;
		
		do {
			do {
				System.out.println("Choose next vertex to move");
				for (Integer i:vertexes){
					System.out.print(i+" ");
				}
				System.out.println();
				chosenVertex = scanner.nextInt();
			}while (!vertexes.contains(chosenVertex));
			
			do {
				System.out.println("Choose a vehicle");
				for (Car car:cars){
					System.out.print(iCar + ". " + car+" ");
					iCar++;
				}
				System.out.println();
				iCar = scanner.nextInt();
			}while (!(iCar < cars.size() && iCar>=0));
			chosenCar = cars.elementAt(iCar);
			
		}while(env.getGraph().isEdgeFlooded(position, chosenVertex) && chosenCar.getEff()==0);		
		
		

	}

}
